System, method and computer program product for defining custom junction objects in an on-demand database service

ABSTRACT

In accordance with embodiments, there are provided mechanisms and methods for defining custom junction objects in an on-demand database service. These mechanisms and methods for defining custom junction objects in an on-demand database service can enable embodiments to provide for enhanced security and more efficient querying, etc. The ability of embodiments to provide such features may lead to these and other benefits in an on-line environment.

CLAIM OF PRIORITY

This application claims the benefit of U.S. Provisional PatentApplication 60/957,441 entitled “SYSTEM, METHOD AND COMPUTER PRODUCT FORCUSTOM JUNCTION OBJECTS,” by Simon Wong et al., filed Aug. 22, 2007, theentire contents of which are incorporated herein by reference.

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent file or records, but otherwise reserves all copyrightrights whatsoever.

FIELD OF THE INVENTION

The current invention relates generally to database systems, and moreparticularly to defining custom junction objects.

BACKGROUND

The subject matter discussed in the background section should not beassumed to be prior art merely as a result of its mention in thebackground section. Similarly, a problem mentioned in the backgroundsection or associated with the subject matter of the background sectionshould not be assumed to have been previously recognized in the priorart. The subject matter in the background section merely representsdifferent approaches, which in and of themselves may also be inventions.

In conventional database systems, users access their data resources inone logical database. A user of such a conventional system typicallyretrieves data from and stores data on the system using the user's ownsystems. A user system might remotely access one of a plurality ofserver systems that might in turn access the database system. Dataretrieval from the system might include the issuance of a query from theuser system to the database system. The database system might processthe request for information received in the query and send to the usersystem information relevant to the request.

There is often a desire to define custom junction objects in theforegoing database frameworks. To date, such custom junction objectshave been limited to traditional database frameworks. To this end, thevarious benefits that may optionally be derived from such customjunction objects have been void in on-line environments.

BRIEF SUMMARY

In accordance with embodiments, there are provided mechanisms andmethods for defining custom junction objects in an on-demand databaseservice. These mechanisms and methods for defining custom junctionobjects in an on-demand database service can enable embodiments toprovide for enhanced security and more efficient querying, etc. Theability of embodiments to provide such features may lead to these andother benefits in an on-line environment.

In an embodiment and by way of example, a method is provided forreceiving information associated with a plurality of arbitrary objects.Further, a custom junction object is defined comprising a many-to-manyrelationship of any tuple selected from the arbitrary objects. Stillyet, information about related tuples of arbitrary objects is stored inan on-demand database service using the definition.

While the present invention is described with reference to an embodimentin which techniques for defining custom junction objects in an on-demanddatabase service are implemented in an application server providing afront end for a multi-tenant database on-demand service, the presentinvention is not limited to multi-tenant databases or deployment onapplication servers. Embodiments may be practiced using other databasearchitectures, i.e., ORACLE®, DB2® and the like without departing fromthe scope of the embodiments claimed.

Any of the above embodiments may be used alone or together with oneanother in any combination. Inventions encompassed within thisspecification may also include embodiments that are only partiallymentioned or alluded to or are not mentioned or alluded to at all inthis brief summary or in the abstract. Although various embodiments ofthe invention may have been motivated by various deficiencies with theprior art, which may be discussed or alluded to in one or more places inthe specification, the embodiments of the invention do not necessarilyaddress any of these deficiencies. In other words, different embodimentsof the invention may address different deficiencies that may bediscussed in the specification. Some embodiments may only partiallyaddress some deficiencies or just one deficiency that may be discussedin the specification, and some embodiments may not address any of thesedeficiencies.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows a method for defining custom junction objects in anon-demand database service, in accordance with one embodiment.

FIG. 2 shows a diagram of a first parent object, a second parent object,and at least one child object that may be used to define a many-to-manyrelationship of a custom junction object, in accordance with oneembodiment.

FIG. 3 shows a method for running a pipeline of queries for returning apredetermined number of temporally ordered entities associated with aplurality of accounts, in accordance with one embodiment.

FIG. 4 shows a diagram illustrating the reduction of a number of rowsper account after running a pipeline of queries, in accordance with oneembodiment.

FIG. 5 illustrates a block diagram of an example of an environmentwherein an on-demand database service might be used.

FIG. 6 illustrates a block diagram of an embodiment of elements of FIG.5 and various possible interconnections between these elements.

DETAILED DESCRIPTION

General Overview

Systems and methods are provided for defining custom junction objects inan on-demand database service.

To date, use of custom junction objects have been limited to traditionaldatabase frameworks. To this end, the various benefits that mayoptionally be derived from such custom junction objects have been voidin on-line environments. Thus, mechanisms and methods are providedherein for defining custom junction objects in an on-demand databaseservice that can enable embodiments to provide for enhanced security andmore efficient querying, etc. in an on-line environment.

Next, mechanisms and methods for defining custom junction objects in anon-demand database service will be described with reference to exemplaryembodiments.

FIG. 1 shows a method 100 for defining custom junction objects in anon-demand database service, in accordance with one embodiment. As shown,information associated with a plurality of arbitrary objects isreceived. See operation 102.

In this case, the objects may include any objects capable of providinginformation. For example, in various embodiments, the arbitrary objectsmay include data associated with activities, opportunities, and cases,etc. In one embodiment, the arbitrary objects may comprise a datastructure (e.g. a table or list) including such data.

Further, a custom junction object comprising a many-to-many relationshipof any tuple selected from the arbitrary objects is then defined. Seeoperation 104. In this case, a tuple refers to any sequence or list ofvalues.

In the context of the present description, a custom junction objectrefers to any object that supports a many-to-many relationship of anytwo arbitrary objects. In this case, a many-to-many relationship refersto any relationship in which a record in a first object (e.g. table,etc.) may correspond to more than one record in a second object. In oneembodiment, the custom junction object may include a many-to-manyrelationship associated with a plurality of the arbitrary objects thathave a business relationship.

With further reference to FIG. 1, information about related tuples ofarbitrary objects is stored in an on-demand database service, using thedefinition. See operation 106. In the context of the presentdescription, an on-demand database service may include any service thatrelies on a database system that is accessible over a network.

In one embodiment, the on-demand database service may include amulti-tenant on-demand database service. In the present description,such multi-tenant on-demand database service may include any servicethat relies on a database system that is accessible over a network, inwhich various elements of hardware and software of the database systemmay be shared by one or more customers. For instance, a givenapplication server may simultaneously process requests for a greatnumber of customers, and a given database table may store rows for apotentially much greater number of customers.

In one embodiment, security criteria associated with the custom junctionobject may be defined and enforced. For example, the custom junctionobject may include a many-to-many relationship associated with a firstparent object, a second parent object, and at least one child object, asshown in FIG. 2. In this case, the security criteria may allow the atleast one child object to be read when both the first parent object andthe second parent object are allowed to be read.

As an option, the security criteria may allow the at least one childobject to be written when both the first parent object and the secondparent object are allowed to be written. As another option, the securitycriteria may allow the at least one child object to be written when boththe first parent object and the second parent object are allowed to beread. As still another option, the security criteria may allow the atleast one child object to be written when at least one of the firstparent object and the second parent object are allowed to be written andat least one of the first parent object and the second parent object areallowed to be read.

In this way, a security model may be applied to the custom junctionobject, where the security model may be inherited from at least one of aset of parents of the custom junction object. As an option, applying asecurity model to the custom junction object may include selectivelyenforcing the security model. As another option, selectively enforcingthe security model may include enforcing the security model when bothparents of the custom junction object are publicly shared, but may notnecessarily be imposed with a database many-to-many relationship table.

In one embodiment, the custom junction object may include a many-to-manyrelationship associated with a plurality of the arbitrary objectsassociated with a single household. In the context of the presentdescription, a household refers to a user-defined grouping of peopleand/or organizations. For example, the household may include a family ora business partnership.

As an option, the household may enable a user to view contactinformation for every member of a household. Furthermore, a householdmay allow the user to view all objects (e.g. activities, cases,solutions, custom objects, etc.) related to the household.

In one embodiment, the custom junction object may support householdfunctionality including household tabs, household tab/object rename,household layouts, household record types, householdoverview/detail/edit, household custom fields, household Apex triggersupport, household custom buttons and links, build data validationsusing Apex triggers/code, and support of custom object tab rename, etc.

A household member may also be configured to include any account of aperson/organization that belongs to a household. In this case, theaccount may belong to multiple households. As a result, the underlyingdata model to support the household member may be a many-to-manyrelationship, as noted above.

In order to build the household member functionality, a new customjunction object may be generated. In one embodiment, the initial customjunction object may be parented by two arbitrary objects (e.g. ahousehold custom object and an account, etc.). In this case, the customjunction object may include a data structure such as a table. As anoption, the visibility of rows of the custom junction object may dependon read-access authorization of a user with respect to both parents.Furthermore, the ability to add/remove rows may depend on edit-access ofa user with respect to both parents.

In one embodiment, the custom junction object may not include sharingrules. For example, the visibility/edit access of the custom junctionobject may be dependent entirely upon the parents. Furthermore, theability to create/update rows may depend on edit-access on both parents.

Because the security of a custom junction object may be dependent uponthe parents, the delete may also be dependent upon the parents. Forexample, a delete of a custom junction object may require access to theparents of both sets of foreign key fields of the parents.

In one embodiment, deleting either parent of the custom junction objectmay cause a cascade delete of the custom junction object. An undelete ofthe parent may also be reflected in the custom junction object, as thecustom junction object may be undeleted as well. However, in some cases,deleting both parents and then undeleting both parents may cause apermanent delete of the custom junction object.

As an option, custom junction objects may not be allowed to havechildren entities such as activities, notes, attachments, childrencustom objects, etc. This may be enforced to simplify the cascade deleteof custom junction objects via their parents.

In one embodiment, on a detail page of either parent of a customjunction object, a custom related list may be provided showing thecustom junction objects related to that parent. For example, if a customjunction object exists between clients and cases, on the detail page ofa particular client, a list of cases in which that client is involvedmay be displayed. Additionally, on the detail page of a particular case,the list of clients to which that case is related may be displayed.

In both cases, the sharing models may be applied such that cases on therelated lists that are not normally displayed will not be displayed,even if the case is related to the particular client being viewed. As anoption, this functionality may be present for every custom junctionobject that any customer builds. In one embodiment, this may beaccomplished by a single database query which performs the stepsillustrated in Table 1.

TABLE 1 1. Start from the Household (e.g. Custom Object) 2. Drive fromHousehold → Household sharing tables (Optional if Household is publicsharing) 3. Drive from Household → Household Member (e.g. CustomJunction Object) via a Household Foreign Key (FK) field on HouseholdMember 4. Drive from Household Member (e.g. Custom Junction Object) →Account via the Account FK on the Household Member 5. Join from Account→ Account sharing tables (Optional if Account is public sharing) 6. JoinAccount

In this case, sharing rules of the objects involved may be optionalbased on the sharing model of each parent. It should be noted that thesecurity joins may be specific to the object parenting the customjunction object. Households and accounts are simply examples used forthis feature, and such examples should not be construed as limiting inany manner.

In some embodiments, related lists may be associated with a singleaccount. For households, related lists of items may be related to anyaccount in the household. If a person account is a member of multiplehouseholds, this may allow entities (e.g. activities, opportunities,cases, etc.) to appear in multiple households. It is the many-to-manynature of junction objects that allows for an account to be related tomultiple households and allows for a household to be related to multipleaccounts. Thus, it is possible to display account X in the detail pageof household Y, and display account X in the detail page of household Z.

In one embodiment, the junction object between a household and accountmay include extra built-in functionality not included in another customjunction object. This functionality, referred to as rollupfunctionality, may be configured such that account may include its ownchild objects, such as opportunities in an account, contacts in anaccount, and other child objects. The junction between household andaccount may be configured such that when one particular household isviewed, it is related to multiple accounts through the household memberjunction objects and each of those accounts are related to their ownsets of opportunities, contacts, and other children. With this rollupfeature, the detail page of a particular household may display a list ofopportunities, contacts, and/or children that are related to any of theaccounts associated with that household. In this way, it may be possibleto see the same opportunity, contact, and/or child X in the detail pageof household Y, and to see X again in the detail page of household Z.This is because the parent account of X is related to both households Yand Z.

Because a single database query may be ran to get all visible accountsrelated to a household or households, and because the visibility ofchild objects is determined by the visibility of the parent, the rollupfunctionality may be implemented by performing an extra database join tothe child object from those visible accounts (e.g. after step 7 in Table1).

When rollup is applied to activities, the set of activities related toany of the accounts that are related to a particular household may bedisplayed. In this case, the visibility of the activity is determined bymultiple factors, rather than just that of the account.

For entity related lists (e.g. activity related lists, etc.), a separatequery may be run to obtain all the accessible accounts in the household.A plsql function may then be called using those account IDs to retrievethe set of IDs of visible activities related to those accounts. Finally,the results from the plsql function may be joined against the activitytable to retrieve those activities.

FIG. 3 shows a method 300 for running a sequence of queries forreturning a predetermined number of temporally ordered entitiesassociated with a plurality of accounts, in accordance with oneembodiment. As an option, the present method 300 may be implemented inthe context of the functionality of FIGS. 1-2. Of course, however, themethod 300 may be carried out in any desired environment. Theaforementioned definitions may apply during the present description.

As shown, a query is run to iterate over entities of a first accountaccording to a son temporal order. See operation 302. In this case, rowsharing may be applied on a per row basis.

As a result of the query, the first N visible entities (e.g. activities,etc.) are received. See operation 304. In this case, N may represent anyinteger. For example, in various embodiments, N may be an integerbetween 1 and 10. Of course, in various other embodiments, N may includeany integer value.

Once received, the received entities are inserted into a sorted list.See operation 306. In this case, the entities may be inserted into thesorted list.

The date of the entities is then stored. See operation 308. In oneembodiment, the entity dates may be stored in an array. It is thendetermined whether there are any remaining accounts. See operation 310.

If there are remaining accounts, the query is run to iterate over theentities. See operation 312. Furthermore, the first available N visibleentities (e.g. activities, etc.) are retrieved and inserted into thesorted list. See operation 314. In this case, the number of visibleentries may be less than the number of the visible entries in the firstquery.

It is then determined whether an entity date of the current row isbeyond a threshold. See operation 316. If the entity date of the currentrow is beyond the threshold, the query is terminated. For example, thequery may be terminated as soon as the entity date of the current row isbeyond the Nth visible account in the sorted list.

At the end of the plsql function, the sorted list of activities isreturned, and the caller may join that against the activity table. Inthis way, while running one query for each account, asymptotically fewerand fewer entity rows per account may be fetched towards the latteraccounts. In this way, by limiting the queries, processing resources andbandwidth resources may be conserved.

In one embodiment, there may be an existing pipeline function thatreturns the ID of visible activities that are related to a givenaccount, ordered by date. This pipeline function may run a query to findactivities related to a given account, determine if the activities arevisible according to the sharing model, and return the visibleactivities one-by-one. As an option, this pipeline functionality may beused in the context of operations 302 and 312 of FIG. 3. It should benoted that when using the method 300 described in FIG. 3, eachsubsequent call to the pipeline function (e.g. using different accountIDs) may return asymptotically fewer and fewer activities, until thethreshold is crossed. Thus, processing resources may be reduced.

FIG. 4 shows a diagram 400 illustrating the reduction of a number ofrows per account after running a pipeline of queries for returning apredetermined number of temporally ordered entities associated with aplurality of accounts A1-AN, in accordance with one embodiment.

In operation, a first query may be run for a predetermined number (e.g.5, etc.) of temporally ordered entities (e.g. activities, cases,solutions, and custom objects, etc.) associated with a first account A1.A second query for temporally ordered entities associated with a secondaccount A2 may then be limited. For example, the second query may belimited by determining whether a date associated with at least one ofthe temporally ordered entities would result in the at least one of thetemporally ordered entities not being included in the predeterminednumber of temporally ordered entities. In this case, the at least one ofthe temporally ordered entity may be conditionally retrieved based onthe determination. Thus, fewer and fewer entity rows per account arefetched as the account number shown in FIG. 4 increases.

System Overview

FIG. 5 illustrates a block diagram of an environment 510 wherein anon-demand database service might be used. As an option, any of thepreviously described embodiments of the foregoing figures may or may notbe implemented in the context of the environment 510. Environment 510may include user systems 512, network 514, system 516, processor system517, application platform 518, network interface 520, tenant datastorage 522, system data storage 524, program code 526, and processspace 528. In other embodiments, environment 510 may not have all of thecomponents listed and/or may have other elements instead of, or inaddition to, those listed above.

Environment 510 is an environment in which an on-demand database serviceexists. User system 512 may be any machine or system that is used by auser to access a database user system. For example, any of user systems512 can be a handheld computing device, a mobile phone, a laptopcomputer, a work station, and/or a network of computing devices. Asillustrated in FIG. 5 (and in more detail in. FIG. 6) user systems 512might interact via a network with an on-demand database service, whichis system 516.

An on-demand database service, such as system 516, is a database systemthat is made available to outside users that do not need to necessarilybe concerned with building and/or maintaining the database system, butinstead may be available for their use when the users need the databasesystem (e.g., on the demand of the users). Some on-demand databaseservices may store information from one or more tenants stored intotables of a common database image to form a multi-tenant database system(MTS). Accordingly, “on-demand database service 516” and “system 516”will be used interchangeably herein. A database image may include one ormore database objects. A relational database management system (RDMS) orthe equivalent may execute storage and retrieval of information againstthe database object(s). Application platform 518 may be a framework thatallows the applications of system 516 to run, such as the hardwareand/or software, e.g., the operating system. In an embodiment, on-demanddatabase service 516 may include an application platform 518 thatenables creation, managing and executing one or more applicationsdeveloped by the provider of the on-demand database service, usersaccessing the on-demand database service via user systems 512, or thirdparty application developers accessing the on-demand database servicevia user systems 512.

The users of user systems 512 may differ in their respective capacities,and the capacity of a particular user system 512 might be entirelydetermined by permissions (permission levels) for the current user. Forexample, where a salesperson is using a particular user system 512 tointeract with system 516, that user system has the capacities allottedto that salesperson. However, while an administrator is using that usersystem to interact with system 516, that user system has the capacitiesallotted to that administrator. In systems with a hierarchical rolemodel, users at one permission level may have access to applications,data, and database information accessible by a lower permission leveluser, but may not have access to certain applications, databaseinformation, and data accessible by a user at a higher permission level.Thus, different users will have different capabilities with regard toaccessing and modifying application and database information, dependingon a user's security or permission level.

Network 514 is any network or combination of networks of devices thatcommunicate with one another. For example, network 514 can be any one orany combination of a LAN (local area network), WAN (wide area network),telephone network, wireless network, point-to-point network, starnetwork, token ring network, hub network, or other appropriateconfiguration. As the most common type of computer network in currentuse is a TCP/IP (Transfer Control Protocol and Internet Protocol)network, such as the global internetwork of networks often referred toas the “Internet” with a capital “I,” that network will be used in manyof the examples herein. However, it should be understood that thenetworks that the present invention might use are not so limited,although TCP/IP is a frequently implemented protocol.

User systems 512 might communicate with system 516 using TCP/IP and, ata higher network level, use other common Internet protocols tocommunicate, such as HTTP, FTP, AFS, WAP, etc. In an example where HTTPis used, user system 512 might include an HTTP client commonly referredto as a “browser” for sending and receiving HTTP messages to and from anHTTP server at system 516. Such an HTTP server might be implemented asthe sole network interface between system 516 and network 514, but othertechniques might be used as well or instead. In some implementations,the interface between system 516 and network 514 includes load sharingfunctionality, such as round-robin HTTP request distributors to balanceloads and distribute incoming HTTP requests evenly over a plurality ofservers. At least as for the users that are accessing that server, eachof the plurality of servers has access to the MTS' data; however, otheralternative configurations may be used instead.

In one embodiment, system 516, shown in FIG. 5, implements a web-basedcustomer relationship management (CRM) system. For example, in oneembodiment, system 516 includes application servers configured toimplement and execute CRM software applications as well as providerelated data, code, forms, webpages and other information to and fromuser systems 512 and to store to, and retrieve from, a database systemrelated data, objects, and Webpage content. With a multi-tenant system,data for multiple tenants may be stored in the same physical databaseobject, however, tenant data typically is arranged so that data of onetenant is kept logically separate from that of other tenants so that onetenant does not have access to another tenant's data, unless such datais expressly shared. In certain embodiments, system 516 implementsapplications other than, or in addition to, a CRM application. Forexample, system. 516 may provide tenant access to multiple hosted(standard and custom) applications, including a CRM application. User(or third party developer) applications, which may or may not includeCRM, may be supported by the application platform 518, which managescreation, storage of the applications into one or more database objectsand executing of the applications in a virtual machine in the processspace of the system 516.

One arrangement for elements of system 516 is shown in FIG. 6, includinga network interface 520, application platform 518, tenant data storage522 for tenant data 523, system data storage 524 for system dataaccessible to system 516 and possibly multiple tenants, program code forimplementing various functions of system 516, and a process space 528for executing MTS system processes and tenant-specific processes, suchas running applications as part of an application hosting service.Additional processes that may execute on system 516 include databaseindexing processes.

Several elements in the system shown in FIG. 6 include conventional,well-known elements that are explained only briefly here. For example,each user system 512 could include a desktop personal computer,workstation, laptop, PDA, cell phone, or any wireless access protocol(WAP) enabled device or any other computing device capable ofinterfacing directly or indirectly to the Internet or other networkconnection. User system 512 typically runs an HTTP client, e.g., abrowsing program, such as Microsoft's Internet Explorer browser,Netscape's Navigator browser, Opera's browser, or a WAP-enabled browserin the case of a cell phone, PDA or other wireless device, or the like,allowing a user (e.g., subscriber of the multi-tenant database system)of user system 512 to access, process and view information, pages andapplications available to it from system 516 over network 514. Each usersystem 512 also typically includes one or more user interface devices,such as a keyboard, a mouse, trackball, touch pad, touch screen, pen orthe like, for interacting with a graphical user interface (GUI) providedby the browser on a display (e.g., a monitor screen, LCD display, etc.)in conjunction with pages, forms, applications and other informationprovided by system 516 or other systems or servers. For example, theuser interface device can be used to access data and applications hostedby system 516, and to perform searches on stored data, and otherwiseallow a user to interact with various GUI pages that may be presented toa user. As discussed above, embodiments are suitable for use with theInternet, which refers to a specific global internetwork of networks.However, it should be understood that other networks can be used insteadof the Internet, such as an intranet, an extranet, a virtual privatenetwork (VPN), a non-TCP/IP based network, any LAN or WAN or the like.

According to one embodiment, each user system 512 and all of itscomponents are operator configurable using applications, such as abrowser, including computer code run using a central processing unitsuch as an Intel Pentium® processor or the like. Similarly, system 516(and additional instances of an MTS, where more than one is present) andall of their components might be operator configurable usingapplication(s) including computer code to run using a central processingunit such as processor system 517, which may include an Intel Pentium®processor or the like, and/or multiple processor units. A computerprogram product embodiment includes a machine-readable storage medium(media) having instructions stored thereon/in which can be used toprogram a computer to perform any of the processes of the embodimentsdescribed herein. Computer code for operating and configuring system 516to intercommunicate and to process webpages, applications and other dataand media content as described herein are preferably downloaded andstored on a hard disk, but the entire program code, or portions thereof,may also be stored in any other volatile or non-volatile memory mediumor device as is well known, such as a ROM or RAM, or provided on anymedia capable of storing program code, such as any type of rotatingmedia including floppy disks, optical discs, digital versatile disk(DVD), compact disk (CD), microdrive, and magneto-optical disks, andmagnetic or optical cards, nanosystems (including molecular memory ICs),or any type of media or device suitable for storing instructions and/ordata. Additionally, the entire program code, or portions thereof, may betransmitted and downloaded from a software source over a transmissionmedium, e.g., over the Internet, or from another server, as is wellknown, or transmitted over any other conventional network connection asis well known (e.g., extranet, VPN, LAN, etc.) using any communicationmedium and protocols (e.g., TCP/IP, HTTP, HTTPS, Ethernet, etc.) as arewell known. It will also be appreciated that computer code forimplementing embodiments of the present invention can be implemented inany programming language that can be executed on a client system and/orserver or server system such as, for example, C, C++, HTML, any othermarkup language, Java™, JavaScript, ActiveX, any other scriptinglanguage, such as VBScript, and many other programming languages as arewell known may be used. (Java is a trademark of Sun Microsystems, Inc.).

According to one embodiment, each system 516 is configured to providewebpages, forms, applications, data and media content to user (client)systems 512 to support the access by user systems 512 as tenants ofsystem 516. As such, system 516 provides security mechanisms to keepeach tenant's data separate unless the data is shared. If more than oneMTS is used, they may be located in close proximity to one another(e.g., in a server farm located in a single building or campus), or theymay be distributed at locations remote from one another (e.g., one ormore servers located in city A and one or more servers located in cityB). As used herein, each MTS could include one or more logically and/orphysically connected servers distributed locally or across one or moregeographic locations. Additionally, the term “server” is meant toinclude a computer system, including processing hardware and processspace(s), and an associated storage system and database application(e.g., OODBMS or RDBMS) as is well known in the art. It should also beunderstood that “server system” and “server” are often usedinterchangeably herein. Similarly, the database object described hereincan be implemented as single databases, a distributed database, acollection of distributed databases, a database with redundant online oroffline backups or other redundancies, etc., and might include adistributed database or storage network and associated processingintelligence.

FIG. 6 also illustrates environment 510. However, in FIG. 6 elements ofsystem 516 and various interconnections in an embodiment are furtherillustrated. FIG. 6 shows that user system 512 may include processorsystem 512A, memory system 512B, input system 512C, and output system512D. FIG. 6 shows network 514 and system 516. FIG. 6 also shows thatsystem 516 may include tenant data storage 522, tenant data 523, systemdata storage 524, system data 525, User Interface (UI) 530, ApplicationProgram Interface (API) 632, PL/SOQL 634, save routines 636, applicationsetup mechanism 638, applications servers 600 ₁-600 _(N), system processspace 602, tenant process spaces 604, tenant management process space610, tenant storage area 612, user storage 614, and application metadata616. In other embodiments, environment 510 may not have the sameelements as those listed above and/or may have other elements insteadof, or in addition to, those listed above.

User system 512, network 514, system 516, tenant data storage 522, andsystem data storage 524 were discussed above in FIG. 5. Regarding usersystem 512, processor system 512A may be any combination of one or moreprocessors. Memory system 512B may be any combination of one or morememory devices, short term, and/or long term memory. Input system 512Cmay be any combination of input devices, such as one or more keyboards,mice, trackballs, scanners, cameras, and/or interfaces to networks.Output system 512D may be any combination of output devices, such as oneor more monitors, printers, and/or interfaces to networks. As shown byFIG. 6, system 516 may include a network interface 520 (of FIG. 5)implemented as a set of HTTP application servers 600, an applicationplatform 518, tenant data storage 522, and system data storage 524. Alsoshown is system process space 602, including individual tenant processspaces 604 and a tenant management process space 610. Each applicationserver 600 may be configured to tenant data storage 522 and the tenantdata 523 therein, and system data storage 524 and the system data 525therein to serve requests of user systems 512. The tenant data 523 mightbe divided into individual tenant storage areas 612, which can be eithera physical arrangement and/or a logical arrangement of data. Within eachtenant storage area 612, user storage 614 and application metadata 616might be similarly allocated for each user. For example, a copy of auser's most recently used (MRU) items might be stored to user storage614. Similarly, a copy of MRU items for an entire organization that is atenant might be stored to tenant storage area 612. A UI 630 provides auser interface and an API 632 provides an application programmerinterface to system 516 resident processes to users and/or developers atuser systems 512. The tenant data and the system data may be stored invarious databases, such as one or more Oracle™ databases.

Application platform 518 includes an application setup mechanism 638that supports application developers' creation and management ofapplications, which may be saved as metadata into tenant data storage522 by save routines 636 for execution by subscribers as one or moretenant process spaces 604 managed by tenant management process 610 forexample. Invocations to such applications may be coded using PL/SOQL 634that provides a programming language style interface extension to API632. A detailed description of some PL/SOQL language embodiments isdiscussed in commonly owned U.S. Provisional Patent Application60/828,192 entitled, “PROGRAMMING LANGUAGE METHOD AND SYSTEM FOREXTENDING APIS TO EXECUTE IN CONJUNCTION WITH DATABASE APIS,” by CraigWeissman, filed Oct. 4, 2006, which is incorporated in its entiretyherein for all purposes. Invocations to applications may be detected byone or more system processes, which manage retrieving applicationmetadata 616 for the subscriber making the invocation and executing themetadata as an application in a virtual machine.

Each application server 600 may be communicably coupled to databasesystems, e.g., having access to system data 525 and tenant data 523, viaa different network connection. For example, one application server 600,might be coupled via the network 514 (e.g., the Internet), anotherapplication server 600 _(N−1) might be coupled via a direct networklink, and another application server 600 _(N) might be coupled by yet adifferent network connection. Transfer Control Protocol and InternetProtocol (TCP/IP) are typical protocols for communicating betweenapplication servers 600 and the database system. However, it will beapparent to one skilled in the art that other transport protocols may beused to optimize the system depending on the network interconnect used.

In certain embodiments, each application server 600 is configured tohandle requests for any user associated with any organization that is atenant. Because it is desirable to be able to add and remove applicationservers from the server pool at any time for any reason, there ispreferably no server affinity for a user and/or organization to aspecific application server 600. In one embodiment, therefore, aninterface system implementing a load balancing function (e.g., an F5Big-IP load balancer) is communicably coupled between the applicationservers 600 and the user systems 512 to distribute requests to theapplication servers 600. In one embodiment, the load balancer uses aleast connections algorithm to route user requests to the applicationservers 600. Other examples of load balancing algorithms, such as roundrobin and observed response time, also can be used. For example, incertain embodiments, three consecutive requests from the same user couldhit three different application servers 600, and three requests fromdifferent users could hit the same application server 600. In thismanner, system 516 is multi-tenant, wherein system 516 handles storageof, and access to, different objects, data and applications acrossdisparate users and organizations.

As an example of storage, one tenant might be a company that employs asales force where each salesperson uses system 516 to manage their salesprocess. Thus, a user might maintain contact data, leads data, customerfollow-up data, performance data, goals and progress data, etc., allapplicable to that user's personal sales process (e.g., in tenant datastorage 522). In an example of a MTS arrangement, since all of the dataand the applications to access, view, modify, report, transmit,calculate, etc., can be maintained and accessed by a user system havingnothing more than network access, the user can manage his or her salesefforts and cycles from any of many different user systems. For example,if a salesperson is visiting a customer and the customer has Internetaccess in their lobby, the salesperson can obtain critical updates as tothat customer while waiting for the customer to arrive in the lobby.

While each user's data might be separate from other users' dataregardless of the employers of each user, some data might beorganization-wide data shared or accessible by a plurality of users orall of the users for a given organization that is a tenant. Thus, theremight be some data structures managed by system 516 that are allocatedat the tenant level while other data structures might be managed at theuser level. Because an MTS might support multiple tenants includingpossible competitors, the MTS should have security protocols that keepdata, applications, and application use separate. Also, because manytenants may opt for access to an MTS rather than maintain their ownsystem, redundancy, up-time, and backup are additional functions thatmay be implemented in the MTS. In addition to user-specific data andtenant-specific data, system 516 might also maintain system level datausable by multiple tenants or other data. Such system level data mightinclude industry reports, news, postings, and the like that are sharableamong tenants.

In certain embodiments, user systems 512 (which may be client systems)communicate with application servers 600 to request and updatesystem-level and tenant-level data from system 516 that may requiresending one or more queries to tenant data storage 522 and/or systemdata storage 524. System 516 (e.g. an application server 600 in system516) automatically generates one or more SQL statements (e.g. one ormore SQL queries) that are designed to access the desired information.System data storage 524 may generate query plans to access the requesteddata from the database.

Each database can generally be viewed as a collection of objects, suchas a set of logical tables, containing data fitted into predefinedcategories. A “table” is one representation of a data object, and may beused herein to simplify the conceptual description of objects and customobjects according to the present invention. It should be understood that“table” and “object” may be used interchangeably herein. Each tablegenerally contains one or more data categories logically arranged ascolumns or fields in a viewable schema. Each row or record of a tablecontains an instance of data for each category defined by the fields.For example, a CRM database may include a table that describes acustomer with fields for basic contact information such as name,address, phone number, fax number, etc. Another table might describe apurchase order, including fields for information such as customer,product, sale price, date, etc. In some multi-tenant database systems,standard entity tables might be provided for use by all tenants. For CRMdatabase applications, such standard entities might include tables forAccount, Contact, Lead, and Opportunity data, each containingpre-defined fields. It should be understood that the word “entity” mayalso be used interchangeably herein with “object” and “table”.

In some multi-tenant database systems, tenants may be allowed to createand store custom objects, or they may be allowed to customize standardentities or objects, for example by creating custom fields for standardobjects, including custom index fields. U.S. patent application Ser. No.10/817,161, filed Apr. 2, 2004, entitled “CUSTOM ENTITIES AND FIELDS INA MULTI-TENANT DATABASE SYSTEM,” which is hereby incorporated herein byreference, teaches systems and methods for creating custom objects aswell as customizing standard objects in a multi-tenant database system.In certain embodiments, for example, all custom entity data rows arestored in a single multi-tenant physical table, which may containmultiple logical tables per organization. It is transparent to customersthat their multiple “tables” are in fact stored in one large table orthat their data may be stored in the same table as the data of othercustomers.

It should be noted that any of the different embodiments describedherein may or may not be equipped with any one or more of the featuresset forth in one or more of the following published applications:US2003/0233404, titled “OFFLINE SIMULATION OF ONLINE SESSION BETWEENCLIENT AND SERVER,” filed Nov. 4, 2002; US2004/0210909, titled “JAVAOBJECT CACHE SERVER FOR DATABASES,” filed Apr. 17, 2003, now issued U.S.Pat. No. 7,209,929; US2005/0065925, titled “QUERY OPTIMIZATION IN AMULTI-TENANT DATABASE SYSTEM,” filed Sep. 23, 2003; US2005/0223022,titled “CUSTOM ENTITIES AND FIELDS IN A MULTI-TENANT DATABASE SYSTEM,”filed Apr. 2, 2004; US2005/0283478, titled “SOAP-BASED WEB SERVICES IN AMULTI-TENANT DATABASE SYSTEM,” filed Jun. 16, 2004; and/orUS2006/0206834, titled “SYSTEMS AND METHODS FOR IMPLEMENTINGMULTI-APPLICATION TABS AND TAB SETS,” filed Mar. 8, 2005; which are eachincorporated herein by reference in their entirety for all purposes.

While the invention has been described by way of example and in terms ofthe specific embodiments, it is to be understood that the invention isnot limited to the disclosed embodiments. To the contrary, it isintended to cover various modifications and similar arrangements aswould be apparent to those skilled in the art. Therefore, the scope ofthe appended claims should be accorded the broadest interpretation so asto encompass all such modifications and similar arrangements.

The invention claimed is:
 1. A method of implementing a many-to-manyrelationship among objects defined for business entities or businessactivities using database tables in an on-demand database service, themethod comprising: receiving information associated with a plurality ofarbitrary objects defined in the on-demand database service; defining acustom junction object comprising a many-to-many relationship of anytuple selected from the plurality of arbitrary objects, wherein thecustom junction object includes at least a first direct parent-childrelationship implementing the many-to-many relationship that includes afirst parent object and a plurality of child objects, and a secondparent-child relationship that includes a second parent object, and theplurality of child objects; storing in the on-demand database service,custom junction objects including information about related tuples ofarbitrary objects using the custom junction object defined; defining oneor more read-write security criteria associated with the custom junctionobject and enforcing the read-write security criteria, wherein theread-write security criteria applicable to the child objects depend on acombined evaluation of read-write security criteria applicable to boththe first parent object and the second parent object; receiving from asource a first query of a pipeline of queries that when run return apredetermined number of temporally ordered entities associated with aplurality of accounts of the on-demand database service; running thefirst query for a predetermined number of temporally ordered entitiesassociated with a first account; limiting a second query for temporallyordered entities associated with a second account by conditionallyretrieving at least one of temporally ordered entities associated with asecond account based on a determination whether a date associated withthe at least one of the temporally ordered entities would result in theat least one of the temporally ordered entities not being included inthe predetermined number of temporally ordered entities; and using thecustom junction object to provide a result to at least one query,wherein visibility of child objects in the result is determined byvisibility to the source of the first parent object and visibility tothe source of the second parent object; thereby ensuring that the sourcereceives in the result only business entities or business activities ofchild objects whose parent objects are visible to the source.
 2. Themethod of claim 1, wherein combined evaluation of first and secondparents read-write security criteria allows a child object to be writtenwhen both the first parent object and the second parent object areallowed to be read, but not written.
 3. The method of claim 1, whereinthe combined evaluation of first and second parents read-write securitycriteria allows a child object to be written when at least one of thefirst parent object and the second parent object are allowed to bewritten and at least one of the first parent object and the secondparent object are allowed to be read but not written.
 4. The method ofclaim 1, wherein the custom junction object comprises a many-to-manyrelationship associated with a plurality of the arbitrary objectsassociated with a single household.
 5. The method of claim 1, whereinthe custom junction object comprises a many-to-many relationshipassociated with a plurality of the arbitrary objects that have abusiness relationship.
 6. The method of claim 1, wherein the on-demanddatabase service includes a multi-tenant on-demand database service. 7.The method of claim 1, further comprising displaying a detail pageassociated with at least one parent of the custom junction object, thedetail page including a custom related list showing one or more customjunction objects related to at least one parent.
 8. The method of claim1, further comprising displaying a detail page associated with ahousehold, the detail page including a list of children related to oneor more accounts associated with the household.
 9. The method of claim1, wherein the first parent object and the second parent object are bothparent objects to each one of the plurality of child objects.
 10. Themethod of claim 9, wherein the read-write security criteria isselectively enforced by enforcing the read-write security criteria whenboth the first parent object and the second parent object are publiclyshared.
 11. The method of claim 1, wherein the combined evaluation offirst and second parents read-write security criteria allows a childobject to be read when both the first parent object and the secondparent object are allowed to be read.
 12. The method of claim 1, whereinthe combined evaluation of first and second parents read-write securitycriteria allows a child object to be written when both the first parentobject and the second parent object are allowed to be written.
 13. Themethod of claim 1, wherein the on-demand database service includesdatabase tables defining at least one account object, a second object,and a custom junction object that links the account object and thesecond object as parents in a many-to-many relationship with theplurality of child objects as descendants, the method furthercomprising: receiving a request by a user to add a further child objectto the plurality of child objects; determining permission of the user toadd the further child object by evaluating read-write security criteriacontrolling access by the user to the account object and also evaluatingread-write criteria controlling access by the user to the second object;granting to the user, permission to add the further child object thatexceeds the read-write security criteria controlling access by the userto at least one of the account object or to the second object; and usingthe custom junction object to control visibility to the user of thefurther child object, wherein visibility of the further child object tothe user is determined by visibility to the user of the account objectand visibility to the user of the second object; thereby ensuring thatthe user has visibility to only those child objects whose parent objectsare visible to the user.
 14. The method of claim 13, wherein the customjunction object is further linked to permissions data for both theaccount object and the second object and does not include sharing rules.15. The method of claim 14, wherein deletion of the custom junctionobject includes cascading deletion of the plurality of child objects.16. The method of claim 14, wherein the user inherits permission to adda further child from both the account object and the second objectaccording to a rule that the user is granted permission to add a furtherchild object when the user has read but not write access to both theaccount object and the second object.
 17. The method of claim 14,wherein the user inherits permission to add a further child from boththe account object and the second object according to a rule that theuser is granted permission to add a further child object when the userhas read but not write access to one of the account object and thesecond object and has read-write access to an other of the accountobject and the second object.
 18. A non-transitory machine-readablemedium impressed with computer program instructions to implement amany-to-many relationship among objects defined for business entities orbusiness activities using database tables in an on-demand databaseservice, which instructions, when executed, cause one or more processorsto carry out: receiving information associated with a plurality ofarbitrary objects defined in the on-demand database service; defining acustom junction object comprising a many-to-many relationship of anytuple selected from the plurality of arbitrary objects, wherein thecustom junction object includes at least a first direct parent-childrelationship implementing the many-to-many relationship that includes afirst parent object and a plurality of child objects, and a secondparent-child relationship that includes a second parent object, and theplurality of child objects; storing in the on-demand database service,custom junction objects including information about related tuples ofarbitrary objects using the custom junction object defined; defining oneor more read-write security criteria associated with the custom junctionobject and enforcing the read-write security criteria, wherein theread-write security criteria applicable to the child objects depend on acombined evaluation of read-write security criteria applicable to boththe first parent object and the second parent object; receiving from asource a first query of a pipeline of queries that when run return apredetermined number of temporally ordered entities associated with aplurality of accounts of the on-demand database service; running thefirst query for a predetermined number of temporally ordered entitiesassociated with a first account; limiting a second query for temporallyordered entities associated with a second account by conditionallyretrieving at least one of temporally ordered entities associated with asecond account based on a determination whether a date associated withthe at least one of the temporally ordered entities would result in theat least one of the temporally ordered entities not being included inthe predetermined number of temporally ordered entities; and using thecustom junction object to provide a result to at least one query,wherein visibility of child objects in the result is determined byvisibility to the source of the first parent object and visibility tothe source of the second parent object; thereby ensuring that the sourcereceives in the result only business entities or business activities ofchild objects whose parent objects are visible to the source.
 19. Anapparatus, comprising: a processor; and a non-transitory computerreadable memory with one or more stored sequences of computer programinstructions to implement a many-to-many relationship among objectsdefined for business entities or business activities using databasetables in an on-demand database service, which instructions, whenexecuted by the processor, cause the processor to carry out: receivinginformation associated with a plurality of arbitrary objects defined inthe on-demand database service; defining a custom junction objectcomprising a many-to-many relationship of any tuple selected from theplurality of arbitrary objects, wherein the custom junction objectincludes at least a first direct parent-child relationship implementingthe many-to-many relationship that includes a first parent object and aplurality of child objects, and a second parent-child relationship thatincludes a second parent object, and the plurality of child objects;storing in the on-demand database service, custom junction objectsincluding information about related tuples of arbitrary objects usingthe custom junction object defined; defining one or more read-writesecurity criteria associated with the custom junction object andenforcing the read-write security criteria, wherein the read-writesecurity criteria applicable to the child objects depend on a combinedevaluation of read-write security criteria applicable to both the firstparent object and the second parent object; receiving from a source afirst query of a pipeline of queries that when run return apredetermined number of temporally ordered entities associated with aplurality of accounts of the on-demand database service; running thefirst query for a predetermined number of temporally ordered entitiesassociated with a first account; limiting a second query for temporallyordered entities associated with a second account by conditionallyretrieving at least one of temporally ordered entities associated with asecond account based on a determination whether a date associated withthe at least one of the temporally ordered entities would result in theat least one of the temporally ordered entities not being included inthe predetermined number of temporally ordered entities; and using thecustom junction object to provide a result to at least one query,wherein visibility of child objects in the result is determined byvisibility to the source of the first parent object and visibility tothe source of the second parent object; thereby ensuring that the sourcereceives in the result only business entities or business activities ofchild objects whose parent objects are visible to the source.
 20. Amethod for transmitting code for implementing a many-to-manyrelationship among objects defined for business entities or businessactivities using database tables in a multi-tenant database system on atransmission medium, the method comprising: transmitting code forreceiving information associated with a plurality of arbitrary objectsdefined in the multi-tenant database system; transmitting code fordefining a custom junction object comprising a many-to-many relationshipof any tuple selected from the plurality of arbitrary objects, whereinthe custom junction object includes at least a first direct parent-childrelationship implementing the many-to-many relationship that includes afirst parent object and a plurality of child objects, and a secondparent-child relationship that includes a second parent object, and theplurality of child objects; transmitting code for storing in themulti-tenant database system, custom junction objects includinginformation about related tuples of arbitrary objects using the customjunction object defined; transmitting code for defining one or moreread-write security criteria associated with the custom junction objectand enforcing the read-write security criteria, wherein the read-writesecurity criteria applicable to the child objects depend on a combinedevaluation of read-write security criteria applicable to both the firstparent object and the second parent object; transmitting code forreceiving from a source a first query of a pipeline of queries that whenrun return a predetermined number of temporally ordered entitiesassociated with a plurality of accounts of the multi-tenant databasesystem; transmitting code for running the first query for apredetermined number of temporally ordered entities associated with afirst account; transmitting code for limiting a second query fortemporally ordered entities associated with a second account byconditionally retrieving at least one of temporally ordered entitiesassociated with a second account based on a determination whether a dateassociated with the at least one of the temporally ordered entitieswould result in the at least one of the temporally ordered entities notbeing included in the predetermined number of temporally orderedentities; and transmitting code for providing a result to at least onequery using the custom junction object, wherein visibility of childobjects in the result is determined by visibility to the source of thefirst parent object and visibility to the source of the second parentobject.